package com.acme;

/**
 * Class used to calculate simple operations
 * @author S.Zhikdov
 *
 */
public class Task1Calculator {
	public static void main(String[] args) {
		if (args != null && args.length < 3) {
		    throw new IllegalArgumentException("You need enter args in format: " +
		    		                            "'operand' 'operator' 'operand'");
		}

		// throws NumberFormatException - if the string does not contain a parsable double.
		double operand1 = Double.parseDouble(args[0]);
		double operand2 = Double.parseDouble(args[2]);

		double result;

		switch (args[1].charAt(0)) {
        case '+':
            result = operand1 + operand2;
            break;
        case '-':
            result = operand1 - operand2;
            break;
        case '*':
            result = operand1 * operand2;
            break;
        case '/':
            result = operand1 / operand2;
            break;
        default:
            throw new IllegalArgumentException("Illegal operator: " + args[1]);
        }

		System.out.println("Result = " + result);
	}

}
